package com.lupan.classicsJava.jpa.domain;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * 说明：班级
 *
 * @author lupan
 * @version 2017/3/8 14:25
 */
@Entity
@Table(name = "CLASS")
public class Class extends BaseEntity{

    @Column(nullable = false,unique = true)
    private int classNo;

    @OneToMany(mappedBy = "clazz" , targetEntity = Student.class)
    private Set<Student> students = new HashSet<>();

    @ManyToMany(targetEntity = Teacher.class)
    @JoinTable(
            name="CLASS_TEACHER",
            joinColumns = @JoinColumn(name="teacherId"),
            inverseJoinColumns = @JoinColumn(name="classId")
    )
    private Set<Teacher> teachers = new HashSet<>();

    public int getClassNo() {
        return classNo;
    }

    public void setClassNo(int classNo) {
        this.classNo = classNo;
    }

    public Set<Student> getStudents() {
        return students;
    }

    public void setStudents(Set<Student> students) {
        this.students = students;
    }

    public Set<Teacher> getTeachers() {
        return teachers;
    }

    public void setTeachers(Set<Teacher> teachers) {
        this.teachers = teachers;
    }
}
